package com.app.piemoment.entity;

import org.json.JSONException;
import org.json.JSONObject;

import android.os.Parcel;
import android.os.Parcelable;

public class Address implements Parcelable{

	private long areaCode;
	private String area;

	public Address() {
		super();
	}

	Address(Parcel in) {
		this.areaCode = in.readLong();
		this.area = in.readString();
	}

	public static final Parcelable.Creator<Address> CREATOR = new Creator<Address>() {
		@Override
		public Address[] newArray(int size) {
			return new Address[size];
		}

		@Override
		public Address createFromParcel(Parcel source) {
			return new Address(source);
		}
	};

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeLong(areaCode);
		dest.writeString(area);
	}
	

	
	public long getAreaCode() {
		return areaCode;
	}

	public void setAreaCode(long areaCode) {
		this.areaCode = areaCode;
	}

	public String getArea() {
		return area;
	}

	public void setArea(String area) {
		this.area = area;
	}

	public void parser(JSONObject jsonObject) throws JSONException {
		if(jsonObject!=null) {
			if(jsonObject.has("code")) {
				setAreaCode(jsonObject.getLong("code"));
			}
			if(jsonObject.has("name")) {
				setArea(jsonObject.getString("name"));
			}
			
		}
	}

}
